<template>
  <div class="user-info">
    <el-row :span="24">
      <el-col :span="8">
        <el-container class="user-info__box">
          <div class="user-info__content">
            <img
              class="user-info__img"
              :src="userInfo.avatar"
              alt=""
            >
            <p class="user-info__name">{{ userInfo.name }}</p>
            <p class="user-info__desc">{{ userInfo.loginId }}</p>
            <div class="user-info__detail-desc">
              <p><i class="el-icon-user" />
                <span title="用户姓名">{{ userInfo.userName }}</span>
              </p>
              <p><i class="el-icon-phone" /><span title="手机号">{{ userInfo.telephone }}</span></p>
              <p><i class="el-icon-message" /><span title="邮箱">{{ userInfo.email }}</span></p>
              <p><i class="el-icon-postcard" /><span title="所在部门">{{ userInfo.orgName }}</span></p>
              <p><i class="el-icon-guide" /><span title="邮编">{{ userInfo.postCode }}</span></p>
              <p><i class="el-icon-location-information" /><span title="地址">{{ userInfo.address }}</span></p>
            </div>
            <div class="user-info__divider" />
            <h4>登录信息</h4>
            <div class="user-info__detail-desc">
              <p><i class="el-icon-time">最后登录时间：</i><span>{{ userInfo.lastLoginTime }}</span></p>
              <p><i class="el-icon-collection-tag">登录次数：</i><span>{{ userInfo.loginCount }}</span></p>
            </div>
          </div>
        </el-container>
      </el-col>
      <el-col :span="16">
        <el-container>
          <el-tabs v-model="activeName">
            <el-tab-pane label="个人信息" name="userInfo">
              <!-- <userInfo :emit-data="userInfo" /> -->
              <userCard :emit-data="userInfo" />
            </el-tab-pane>
            <el-tab-pane label="修改密码" name="editPw">
              <editPW @handleBoxEvent="handleBoxEvent" />
            </el-tab-pane>
          </el-tabs>
        </el-container>
      </el-col>
    </el-row>

  </div>
</template>

<script>
import store from '@/store/'
import editPW from './widget/editPw'
import userCard from './widget/userCard'
import { mapActions } from 'vuex'
export default {
  components: {
    userCard,
    editPW
  },
  data() {
    return {
      userInfo: store.getters.userInfo,
      activeName: 'userInfo'
    }
  },
  computed: {
    ...mapActions('user', ['resetPassword'])
  },
  created() {
  },
  methods: {
    handleBoxEvent(obj) {
      if (obj.RNewPw !== obj.newPw) {
        this.$message.error('新密码和确认密码不一致')
      } else {
        this.resetPassword(obj)
      }
    }
  }
}
</script>

<style lang="scss">
.user-info {
  background: transparent;
  .avue-tabs {
    padding: 0 10px;
  }
  &__box{
    position: relative;
    &::after{
      content: '';
      position: absolute;
      width: 10px;
      height: 150%;
      background: #f0f0f0;
      right: 10px;
      top: -20px
    }
  }
  .el-tabs__content {
    padding: 20px 0;
  }
  &__img {
    display: block;
    margin: 0 auto;
    border-radius: 100%;
    width: 100px;
    height: 100px;
  }
  &__name {
    text-align: center;
    font-size: 20px;
    line-height: 28px;
    font-weight: 500;
    color: rgba(0, 0, 0, 0.85);
    margin-bottom: 0;
    margin-top: 10px;
  }
  &__setting {
    margin-bottom: 12px;
    display: block;
    font-size: 12px;
    color: #409eff;
    text-align: center;
  }
  &__desc {
    text-align: center;
    width: 200px;
    margin: 0 auto;
  }
  &__detail-desc {
    margin-top: 50px;
    font-size: 14px;
    p {
      margin-bottom: 10px;
    }
    span {
      margin-left: 10px;
    }
  }
  &__divider {
    border-top: 1px dashed #e8e8e8;
    display: block;
    height: 0;
    width: 100%;
    margin: 24px 0;
    clear: both;
  }
  &__tags {
    .el-tag {
      margin: 0 5px 5px 0;
    }
  }
}
</style>
